﻿package org.dm.3d.Actions.object 
{
	import org.dm.3d.Actions.Action;
	import org.dm.3d.cameras.CameraBase;
	import org.dm.3d.geom.Num3D;
	import org.dm.3d.geom.MathExtend;
	
	/**
	 * ...
	 * @author Scott
	 */
	public class ComeBack extends Action
	{
		public var _cur:uint = 0;
		private var cam:CameraBase;
		public function ComeBack(pcam:CameraBase) 
		{
			cam = pcam;
		}
		public override function update(items:Array, num:uint):void 
		{
			_cur++;
			var pos:Num3D;
			var csin:Number = Math.sin(cam.angle.x);
			var ccos:Number = Math.sin(cam.angle.y);
			var tempx:Number;
			for (var i:uint = 0; i < num; i++)
			{
				pos = items[i].pos.subtract(cam.pos);
				pos.x = ccos*pos.x - csin*pos.z;
				if (pos.x < 0)
				{
					items[i].pos = MathExtend.pInRing(1, cam.pos.x, 1500, 500);
				}
			}
		}
	}
	
}